package com.example.baozidemo.exception;

import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.http.HttpStatus;

/**
 * 自定义异常
 *
 * @author steed
 * @since 2020/11/11
 **/
@Data
@EqualsAndHashCode(callSuper = true)
public class HttpException extends RuntimeException {

    private static final long serialVersionUID = 1L;

    private int code;

    private String msg;

    public HttpException(String msg, Throwable e) {
        super(msg, e);
        this.msg = msg;
    }

    public HttpException(String message, Integer code) {
        this.code = code;
        this.msg = message;
    }

    public HttpException(String msg) {
        super(msg);
        this.code = HttpStatus.INTERNAL_SERVER_ERROR.value();
        this.msg = msg;
    }
}
